/**
 * @(#)Test.java 2014年12月17日
 * <p>
 * Copyright (c) 2010 35.com, Inc. All rights reserved.
 */
package com.example.demo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * 分组小程序
 *
 * @author 李志恩
 * @version 1.0.0
 */
public class Group {
    public static void main(String[] args) {
        try {
            String[] a = {"李志恩", "龙江", "郭镇平", "林锡沧"};
            String[] b = {"吴明", "张全贺", "罗天水", "范启贤"};
            String[] c = {"李海龙", "肖伟权", "纪谋杰", "龚子雄"};
            String[] d = {"李容珠", "李开荣", "金长生", "张世洪"};

            Map group = new ConcurrentSkipListMap<String, String>();

            for (int i = 1; i <= 4; i++) {
                Random random = new Random();

                //抽A
                int rand = random.nextInt(a.length);
                group.put(i + "组A", a[rand]);
                ArrayList<String> lista = new ArrayList<>(Arrays.asList(a));
                lista.remove(rand); // 根据索引位置删除
                a = lista.toArray(new String[0]);

                //抽B
                rand = random.nextInt(b.length);
                group.put(i + "组B", b[rand]);
                ArrayList<String> listb = new ArrayList<>(Arrays.asList(b));
                listb.remove(rand); // 根据索引位置删除
                b = listb.toArray(new String[0]);

                //抽C
                rand = random.nextInt(c.length);
                group.put(i + "组C", c[rand]);
                ArrayList<String> listc = new ArrayList<>(Arrays.asList(c));
                listc.remove(rand); // 根据索引位置删除
                c = listc.toArray(new String[0]);

                //抽D
                rand = random.nextInt(d.length);
                group.put(i + "组D", d[rand]);
                ArrayList<String> listd = new ArrayList<>(Arrays.asList(d));
                listd.remove(rand); // 根据索引位置删除
                d = listd.toArray(new String[0]);
            }

            System.out.println("分组完成：" + group.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
